package com.culturalCenter.dataCenter.Utils;

import javax.servlet.http.HttpServletRequest;

public class FrameUtils {

    /**
     * 判断请求来自手机端还是电脑端
     */
    public static boolean isMobileDevice(HttpServletRequest request) {
        /*
          android : 所有android设备
          mac os : iphone ipad
          windows phone:Nokia等windows系统的手机
         */
        String[] deviceArray = {"android", "iphone", "ipod", "ipad", "windows phone", "mqqbrowser"};
        String requestHeader = request.getHeader("User-Agent");
        if (requestHeader == null) {
            return false;
        }
        requestHeader = requestHeader.toLowerCase();
        if (requestHeader.contains("windows nt") || requestHeader.contains("macintosh")) {
            return false;
        }
        for (String s : deviceArray) {
            if (requestHeader.contains(s)) {
                return true;
            }
        }
        return false;
    }

}
